/*
 * 全时云商务服务股份有限公司.
 * Copyright © 2021 京icp备08005473号. All rights reserved.
 * @Date: 2021-09-02.
 * @Author：
 * @Description 小课堂 - 课程 - 首页
 **/
import React, { memo, useState, useEffect } from "react"
import Taro from '@tarojs/taro'
import { View,  Image } from '@tarojs/components'
import './index.scss'
import noCourse from "../../assets/no-course.png"
import CourseCard from "../../components/CourseCard/index"

/**
 *@Description
 *@Return  课程.
**/
const CoursePage: React.FC = () => {

   const [noData, setNoData] = useState(false) // 暂无数据

  Taro.setBackgroundColor({
    backgroundColor: '#F6F7F6', // 窗口的背景色为白色
  })
  
  Taro.setBackgroundColor({
    backgroundColorTop: '#00D05E', // 顶部窗口的背景色为白色
    backgroundColorBottom: '#F6F7F6', // 底部窗口的背景色为白色
  })

   useEffect(() => {

     setTimeout(() => {
      setNoData(true)
     }, 2000)

     getCourseList()
   }, [])
   /**
    *@Description
    *@Return  获取课程列表.
  **/
  const getCourseList = () => {
    console.log("获取课程列表")
 }

  return (
  <View className='cou-course'>
    {/* banner */}
    <View className='course-banner'></View>
    {/* 课程列表 */}
    <View className='cou-list'>
      {noData ? (
        <View>
          <CourseCard detailUrl='/pages/details/index' setUrl='/pages/classTime/index'></CourseCard>
          <CourseCard detailUrl='/pages/details/index' setUrl='/pages/classTime/index'></CourseCard>
        </View>
      ) : (
        <View className='cou-no-course'>
          <Image src={noCourse}></Image>
          暂无课程
      </View>
      )}
    </View>
  </View>
  )
}

export default memo(CoursePage)

